package org.zoomdev.zoom.dao.adapters.parameter;

import com.alibaba.fastjson2.JSON;
import org.zoomdev.zoom.dao.adapters.ParameterAdapter;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JsonByteArrayParameterAdapter implements ParameterAdapter {
    public static final JsonByteArrayParameterAdapter ADAPTER = new JsonByteArrayParameterAdapter();

    @Override
    public void setNonnullParameter(PreparedStatement ps, int index, Object data) throws SQLException {
        byte[] str = JSON.toJSONBytes(data);
        ps.setBytes(index, str);
    }
}
